package com.bysj.lms.pojo.entity;


import com.baomidou.mybatisplus.annotation.*;
import java.io.Serializable;
import java.time.LocalDateTime;

import com.bysj.lms.pojo.vo.UserVo;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.*;

/**
 * <p>
 * 
 * </p>
 *
 * @author xiaojiakai
 * @since 2022-02-04
 */

@Getter
@Setter
@ToString
@TableName(value = "user")
@NoArgsConstructor
@AllArgsConstructor
@ApiModel("用户模型")
public class User implements Serializable {

    private static final long serialVersionUID = 1L;

    @TableId(type = IdType.ASSIGN_UUID)
    @ApiModelProperty("用户id")
    private String id;

    @ApiModelProperty("用户名")
    private String username;

    @ApiModelProperty("密码")
    private String password;

    @ApiModelProperty("姓名")
    private String name;

    @ApiModelProperty("盐")
    private String salt;

    @ApiModelProperty("电话")
    private String phone;

    @ApiModelProperty(value = "邮箱",required = true)
    private String email;

    @TableField(fill = FieldFill.INSERT)
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @ApiModelProperty(value = "创建时间",notes = "后端生成")
    private LocalDateTime createTime;

    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @ApiModelProperty(value = "最近一次登录时间",notes = "后端生成")
    private LocalDateTime lastLoginTime;

    @ApiModelProperty(value = "用户状态",notes = "0为未锁定,1为锁定")
    private String status;

    public User(UserVo userVo){
        this.id = userVo.getId();
        this.username = userVo.getUsername();
        this.name = userVo.getName();
        this.password = userVo.getPassword();
        this.salt = userVo.getSalt();
        this.phone = userVo.getPhone();
        this.email = userVo.getEmail();
        this.status = userVo.getStatus()==null? "0":userVo.getStatus();
    }
}
